package com.gdth.core.widget;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;

/** 
 * @author  Arvin
 * @version 2016-5-3 11:45:57 
 * 
 */
public class BaseFragment extends Fragment{
	
	private int layout;
	
	public View rootView;
	
	public FragmentActivity activity;
	
	public BaseFragment(){
	}
	
	public BaseFragment(int layout){
		this.layout = layout;
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//		关联布局文件  
		rootView = inflater.inflate(this.layout, container, false);

		return rootView;  
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState){
		super.onActivityCreated(savedInstanceState);
		
		AnnotationUtil.initInjectedFragment(this);
		this.activity = this.getActivity();
		initializeView();
		initializePresenter();
	}
	
	public void initializeView(){};
	
	public void initializePresenter(){};
	
	protected void showToastMessage(String message) {
		Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
	}
	
	@Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
		// TODO Auto-generated method stub
		if (isVisibleToUser) {
			//fragment可见时加载数据
	    } else {
	        //不可见时不执行操作
	    }
		
		super.setUserVisibleHint(isVisibleToUser);
    }
}
